﻿//----------------------------------------------------------------
// Desc: 
// Edit: ShowLong, http://blog.csdn.net/showlong
//
// Date Created: 2012-04-13
//
// Update Date : 
//
// Copyright (c) Fuel4D (http://www.fuel4d.com), All rights reserved.
//
//----------------------------------------------------------------
#pragma once


class IFStrClipQuery : public IFMemObject
{
public:
    // .query_char true查询字符，false查询字符串
    // .返回该字符或者字符串所战象素宽度
    virtual size_t GetWidth(const WCHAR* psz, bool query_char) = 0;
};


class FAutoDll : IFMemObject
{
    FDECLARE_CLASS(FAutoDll);

    FAutoDll()
        :hins(0)
    {
    }
    FAutoDll(const WCHAR* file)
    {
        hins = FDllOpenW(file);
    }
    FAutoDll(const ACHAR* file)
    {
        hins = FDllOpenA(file);
    }
    ~FAutoDll()
    {
        FDllClose(hins);
    }
    FINLINE void Load(const WCHAR* file)
    {
        FDllClose(hins);
        hins = FDllOpenW(file);
    }
    FINLINE void Load(const ACHAR* file)
    {
        FDllClose(hins);
        hins = FDllOpenA(file);
    }
    template < typename _Ty >
    FINLINE bool GetFunc(_Ty& ret, const WCHAR* name)
    {
        ret = (_Ty)FDllGetW(hins, name);
        return ret != 0;
    }
    template < typename _Ty >
    FINLINE bool GetFunc(_Ty& ret, const ACHAR* name)
    {
        ret = (_Ty)FDllGetA(hins, name);
        return ret != 0;
    }
    FINLINE void Release()
    {
        FDllClose(hins);
    }

    HINSTANCE hins;
};
